﻿DECLARE @Var_ReservationDate VARCHAR(100)
DECLARE @Var_DeptCode        VARCHAR(100)
DECLARE @Var_DoctCode        VARCHAR(100)

SET @Var_ReservationDate = @ReservationDate_In;
SET @Var_DeptCode = @DeptCode_In;

SELECT  CASE TimeInterval  WHEN '全天' THEN '1'
                           WHEN '上午' THEN '2'
                           WHEN '上午及下午' THEN '3'
                           WHEN '下午' THEN '4'
        END AS TimeIntervalId,                            
        TimeInterval AS TimeIntervalRange  
FROM dbo.MZSchedule(NOLOCK)
WHERE [Weekday] = DATEPART(WEEKDAY,@Var_ReservationDate) AND KSCode = @Var_DeptCode